<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
	<jsp:include page="../inc.jsp"/>
<jsp:include page="../inc_bootstrap.jsp"></jsp:include>
	<link rel="stylesheet" href="${ctx }/css/settlementQuery.css"/>
<meta http-equiv="X-UA-Compatible" content="edge" />
<title>业务报表</title>
<link rel="stylesheet" href="${ctx}/css/page.css"/>
<script type="text/javascript">
var tradeType=-1;
$(function(){
	
	//状态背景文字切换
	$(".listArg").click(function(){
		changeBack($(".listArg"),$(this));

	});
	//全选
	$("#query").click(function (){
		gridSearch('');
	});
	//加载列表信息
	$('#table').bootstrapTable({
		url: '${ctx}/tradeList/purRepManage?temp='+Math.random(),
		dataType: "json",
		//contentType: "application/x-www-form-urlencoded",
		method: 'get',
		cache: false,
		height: "auto",//
		pagination: true,
		pageSize: 20,
		pageNumber:1,
		pageList: [ 20, 50, 100, 200, 500],
		striped: false,
		search: false,
		showColumns: false,
		showRefresh: false,
		clickToSelect: true,
		idField:'id',
		//toolbar: "#toolbar",
		paginationHAlign: 'left',
		paginationDetailHAlign: 'right',
		sidePagination: "server", //表示服务端请求
		queryParamsType : "undefined",
		//queryParams: queryParams,//参数
		columns: [
			{field:"id",title:"",align:"left",valign:"middle",visible:false},
			{field:"payOrderNumber",title:"支付单号",align:"left",valign:"middle"},
			{field:"organizationName",title:"采购商",align:"left",valign:"middle"},
			{field:"cc",title:"类型",align:"left",valign:"middle",
				formatter : function(value,row,index){
					var str=CommonConverter.toTradeType(row.tradeType);
					return str;
				}
			},
			{field:"aa",title:"金额",align:"left",valign:"middle",
				formatter : function(value,row,index){
					var str=row.cost;
					if(row.tradeType == 3){
						str=row.income;
					};
					return str;
				}
			},
			{field:"createTime",title:"操作日期",align:"left",valign:"middle"},
			{field:"dd",title:"账户金额（CNY）",align:"left",valign:"middle",
				formatter:function(value,row,index){
					var str=CommonConverter.toZero(row.accountBalance);
					return str;
				}
			},
			{field:"ff",title:"可用金额",align:"left",valign:"middle",
				formatter:function(value,row){
					var str=CommonConverter.toZero(row.availableBalance);
					return str;
				}
			},
			{field:"freezeAmount",title:"冻结金额",align:"left",valign:"middle"}
		],
		formatNoMatches: function(){
			return '无符合条件的记录';
		}
	});
});
//导出表格
function exportExcel(){
	var organizationName=$("#organizationName").val();
	var startDate=$("#startdate").val();
	var endDate=$("#endDate").val();
	var url = "${ctx}/excel/exportSheets1?organizationName="+organizationName
			+"&startDate="+startDate
			+"&endDate="+endDate
			+"&tradeType"+tradeType
			+"&temp="+Math.random();
	window.location.href = url;
};

//封装函数  实现背景颜色及字体颜色切换
function changeBack(arg,$this){
	arg.css({
		"background": "#f1f1f1",
		"color": "black"
	});
	$this.css({
		"background": "#28aaf0",
		"color": "#FFFFFF"
	});
};

function gridSearch(status) {
	var organizationName="";//提现单号
	var startDate="";//申请日期
	var endDate="";//结束日期
	organizationName=$("#organizationName").val();
	startDate=$("#startDate").val();
	endDate=$("#endDate").val();
	tradeType =status;
	var param = {query:{
		pageNumber: 1,
		pageSize: 20,
		organizationName:organizationName,
		startDate:startDate,
		endDate:endDate,
		tradeType:status
	}};
	$('#table').bootstrapTable('refresh',param);
}

</script>
</head>
<body>
<jsp:include page="../head.jsp"/>
	<div class="content">
			<ul class="list">
				<li>采购商：
					<input type="text" id="organizationName" style="height:18px;">
				</li>
				<li>
					操作日期 ：<input type="text" style="height:18px" id="startDate" class="textbox" value="${requestScope.deptDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'%y-%M-\#{%d+2}',maxDate:'#F{$dp.$D(\'endDate\')}'*/})"/>
						<img class="city" src="${ctx}/image/date.gif">&nbsp;&nbsp;&nbsp;&nbsp;
						至<input type="text" style="height:18px" id="endDate" class="textbox" value="${requestScope.endDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'#F{$dp.$D(\'startDate\')}'*/})">
						<img class="city" src="${ctx}/image/date.gif">
				</li>
				<li>
				<li class="right">
					<button class='query' onclick="exportExcel()">导出</button>
				</li>
				<li class="right">
					<button class='query' id="query">查询</button>
				</li>
			</ul>
			<ul class="list conditionList">
		         	<li>状态：</li>
					<li  class="listArg allStatus" onclick="gridSearch('')">
						<span>全部</span>
					</li>
					<li class="listArg " onclick="gridSearch('0')">
						<span >票款</span>
					</li>
					<li class="listArg " onclick="gridSearch('1')">
						<span >冻结</span>
					</li>
					<li class="listArg " onclick="gridSearch('2')">
						<span >提现</span>
					</li>
					<li class="listArg " onclick="gridSearch('3')">
						<span >充值</span>
					</li>
					<li class="listArg " onclick="gridSearch('4')">
						<span >解冻</span>
					</li>
				</ul>
		<div class="setTabBox">
				<table id="table"></table>
		</div>
	</div>
<jsp:include page="../footer.jsp"/>
</body>
</html>